/*
 * genPacketHandler.h
 *
 * Created: 6/18/2013 1:34:55 AM
 *  Author: Tim
 */ 


#ifndef GENPACKETHANDLER_H_
#define GENPACKETHANDLER_H_

#include <avr/io.h>
#include "../CRC.h"
#include "../../communication/comPort.h"
#include "../../packets/CRC.h"
#include "../../packets/structs/msgHeaderDefs.h"
#include "../../packets/structs/genPacketStructs.h"
#include "../../features/stateMachine.h"

static inline void sendGenAck(uint8_t ackMsgHeader, uint8_t errStat)
{
	xtrg_t packet;

	packet.Header		= packetHeader;
	packet.msgHeader	= ack_mh;
	
	packet.ackedHeader	= ackMsgHeader;
	packet.status		= errStat;
	
	crcAppend(&packet,packetSizeLookup(ack_mh));
	comPortPut(&packet,packetSizeLookup(ack_mh));
}

static inline void sendDaqReady()
{
	daqReady_t packet;
	
	packet.Header = packetHeader;
	packet.msgHeader = daqReady_mh;
	
	crcAppend(&packet,packetSizeLookup(daqReady_mh));
	comPortPut(&packet,packetSizeLookup(daqReady_mh));
}

#endif